<?php

namespace app\model;

use think\Model;

class TuanFollow extends Model
{
    protected $connection = 'mysql';

    protected $pk = 'id';

    protected $name = 'tuan_follow';

    static public function add_follow($param)
    {
        $Membermob = new Member;
        $Member = $Membermob->getUserByWechat();
        $TuanFound = TuanFound::find($param['found_id']);

        $data['uid'] = $Member['id'];
        $data['nickname'] = $Member['nickname'];
        $data['avatar'] = $Member['userpic'];

        $data['join_time'] = time();
        $data['order_id'] = $param['order_id'];
        $data['found_id'] = $param['found_id'];
        $data['tuan_id'] = $param['tuan_id'];
        $data['is_head'] = $param['is_head'];
        $data['is_robot'] = $param['is_robot'];
        $data['tuan_end_time'] = $TuanFound->tuan_end_time;

        $res = self::create($data);
        return $res->id;
    }
}
